package com.rd.student.jiaji.class3.sunguowei.day25;

import java.io.File;
import java.io.IOException;

public class Test {
    public static void main(String[] args) {
        String projectPath=System.getProperty("user.dir");
        File file1=new File(projectPath+"\\"+"f1");
        File file2=new File(projectPath+"\\"+"f2");
        Boolean result1 = file1.mkdir();
        if (result1) {
            System.out.println("文件夹创建成功");
        } else {
            System.out.println("文件夹创建失败");
        }
        Boolean result2 = file2.mkdir();
        if (result2) {
            System.out.println("文件夹创建成功");
        } else {
            System.out.println("文件夹创建失败");
        }
        File t1=new File(file1+"\\"+"t1.txt");
        File t2=new File(file1+"\\"+"t2.txt");
        File t3=new File(file2+"\\"+"t3.txt");
        File t4=new File(file2+"\\"+"t4.txt");
        try {
            t1.createNewFile();
            t2.createNewFile();
            t3.createNewFile();
            t4.createNewFile();

        } catch (IOException e) {
            throw new RuntimeException(e);
        }

        System.out.println("------------------------------");
        File file3=new File(projectPath+"\\"+"f3");
        file3.mkdir();
        File file4=new File(projectPath+"\\"+"f4");

        Boolean result=file3.renameTo(file4);
        if(result){
            System.out.println("文件夹重命名成功");
        }else{
            System.out.println("文件夹命名失败");
        }

        System.out.println("------------------------------");

        Boolean result4=file4.delete();
        if(result4){
            System.out.println("文件夹删除成功");
        }else{
            System.out.println("文件夹删除失败");
        }

        System.out.println("-----------------");

        File parentFile1 = file1.getParentFile();
        String[] strList1 = parentFile1.list();
        for (String s : strList1) {
            System.out.println(s);

        }
        File parentFile2 = file2.getParentFile();
        String[] strList2 = parentFile2.list();
        for (String s : strList2) {
            System.out.println(s);

        }



    }
}
